home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performPointCurveConstraint. < prev    next >
Encoding:
Text File  |  2003-07-17  |  5.2 KB  |  202 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 20, 1997
  22. //  Author:         ramesh 
  23. //
  24. //  Description:
  25. //      This script defines option box for the pointCurveConstraint menu item.
  26. //
  27. //  Input Arguments:
  28. //      int action  
  29. //            0 - just execute the command.
  30. //            1 - show option box dialog.
  31. //            2 - return the drag command.
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. proc setOptionVars (int $forceFactorySettings)
  37. {
  38.     pointCurveConstraintSetOptionVars( $forceFactorySettings );
  39. }
  40.  
  41. proc createPointCurveConstraintUI( string $parent )
  42. {
  43.     setParent $parent ;
  44.  
  45.     columnLayout pointCurveConstraintOptionsColumnLayout;
  46.         //
  47.         // cos for the first or both surfaces ?
  48.         //
  49.         checkBoxGrp -ncb 1 
  50.             -label "" 
  51.             -label1 "Keep Original" 
  52.             constraintKeepOriginalBoxGrp ;
  53.         floatSliderGrp 
  54.             -field true -min 0.1 -max 10.0 -l "Point Weight" 
  55.             constraintWtSlider;
  56.     setParent .. ;
  57. }
  58.  
  59. proc string assembleCmd()
  60. {
  61.     string $cmd ;
  62.     setOptionVars(false) ;
  63.  
  64.     // query the settings for cmd(s).    
  65.     //
  66.     int $doHistory = `constructionHistory -q -tgl`;
  67.     int $keepOriginal = `optionVar -q pointCurveConstraintKeepOriginal` ;
  68.     float $wt = `optionVar -q pointCurveConstraintWt` ;
  69.     $cmd = "pointCurveConstraintPreset" ;
  70.     $cmd = $cmd + "( " + $doHistory + " ," + $keepOriginal + " , " + $wt + ")";
  71.     return $cmd ;    
  72. }
  73.  
  74. proc pointCurveConstraintOptions()
  75. {
  76.     string $commandName = "pointCurveConstraint" ;
  77.     string $optionBoxTitle = "Point On Curve Options" ;
  78.     string $applyTitle = "Create";
  79.  
  80.  
  81.     // build option box methods.
  82.     //
  83.     string $callback = ($commandName + "Callback");        
  84.     string $setup = ($commandName + "Setup");
  85.  
  86.     string $layout = getOptionBox();
  87.     setParent $layout;
  88.  
  89.     setOptionBoxCommandName($commandName);
  90.     setUITemplate -pushTemplate DefaultTemplate;
  91.     waitCursor -state 1;
  92.     tabLayout -tabsVisible false -scr true;
  93.     string $parent = `columnLayout -adjustableColumn 1`;
  94.     createPointCurveConstraintUI($parent);
  95.     waitCursor -state 0;
  96.     setUITemplate -popTemplate;
  97.  
  98.     string $applyBtn = getOptionBoxApplyBtn();
  99.     button -edit -label $applyTitle 
  100.         -command ($callback + " " + $parent + " " + 1) 
  101.         $applyBtn;
  102.  
  103.     //  'Save' button.
  104.     //
  105.     string $saveBtn = getOptionBoxSaveBtn();
  106.     button -edit 
  107.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") 
  108.         $saveBtn;
  109.  
  110.     //  'Reset' button.
  111.     //
  112.     string $resetBtn = getOptionBoxResetBtn();
  113.     button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn;
  114.  
  115.     //  Set the option box title.
  116.     //
  117.     setOptionBoxTitle($optionBoxTitle);
  118.  
  119.     //    Customize the 'Help' menu item text.
  120.     //
  121.     setOptionBoxHelpTag( "PointOnCurve" );
  122.         
  123.     eval (($setup + " " + $parent + " " + 0));
  124.     showOptionBox();
  125. }
  126.  
  127.  
  128. global proc pointCurveConstraintSetup(
  129.     string $parent,
  130.     int $forceFactorySettings)
  131. {
  132.     // retrieve option settings.
  133.     //
  134.     setOptionVars($forceFactorySettings);    
  135.     setParent $parent;    
  136.  
  137.     // query all the option vars and set the controls.
  138.     //
  139.     int $keepOriginal = `optionVar -q pointCurveConstraintKeepOriginal` ;
  140.     checkBoxGrp -edit -v1 $keepOriginal constraintKeepOriginalBoxGrp ;
  141.  
  142.     float $wt = `optionVar -q pointCurveConstraintWt` ;
  143.     floatSliderGrp -edit -value $wt constraintWtSlider ;    
  144. }
  145.  
  146.  
  147. global proc pointCurveConstraintCallback(
  148.      string $parent,
  149.      int $doIt )
  150. {
  151.     setParent $parent ;
  152.  
  153.     // get Values from controls.
  154.     //
  155.     int $keepOriginal = `checkBoxGrp -q -v1 constraintKeepOriginalBoxGrp`;
  156.     float $wt = `floatSliderGrp -q -value constraintWtSlider` ;    
  157.  
  158.     optionVar -floatValue pointCurveConstraintWt $wt ;
  159.     optionVar -intValue pointCurveConstraintKeepOriginal $keepOriginal ;
  160.  
  161.     if ($doIt) {
  162.         performPointCurveConstraint(0) ;
  163.         addToRecentCommandQueue "performPointCurveConstraint 0" "PointCurve Constraint";
  164.     }
  165. }
  166.  
  167. global proc string performPointCurveConstraint( 
  168.     int $action )
  169. //
  170. // Description :
  171. //        0 - do the command.
  172. //        1 - show the option box.
  173. //        2 - return the drag command.    
  174. //    
  175. {
  176.  
  177.     string $cmd = "" ;
  178.     switch( $action ) {
  179.         case 0 :
  180.             // do the cmd.
  181.             //
  182.             setOptionVars(false) ;
  183.             $cmd = `assembleCmd` ;
  184.             eval($cmd) ;
  185.             break ;
  186.         case 1 :
  187.             // option Box.
  188.             //
  189.             pointCurveConstraintOptions ;
  190.             break ;
  191.         case 2 :
  192.             // return the drag string with the set options
  193.             // on to shelf
  194.             //
  195.             $cmd = `assembleCmd` ;
  196.             break ;    
  197.  
  198.     }
  199.     return $cmd ;
  200. }
  201.  
  202.